<?php

namespace App\Http\Requests\Admin\Auth;

use Illuminate\Foundation\Http\FormRequest;

/**
 * 用户注册请求逻辑
 *
 * Date: 11/04/2018
 * @author George
 * @package App\Http\Requests\Auth
 */
class RegisterRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

	/**
	 * 定义注册表单规则
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
    public function rules()
    {
        return [
			'mobile' => ['required', 'regex:/^(1[3|4|5|6|7|8|9])\d{9}$/', 'unique:users,mobile'],
			'code' => 'required',
			'password' => 'required|alpha_num|min:6|max:18|confirmed',
			'accepted' => 'accepted'
        ];
    }

	/**
	 * 定义表单验证提示信息
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'mobile.required' => '请输入手机号码',
			'mobile.regex' => '您输入的手机号码不合法',
			'mobile.unique' => '您输入的手机号码已存在',
			'code.required' => '请输入您获取的验证码',
			'password.required' => '请输入密码',
			'password.alpha_num' => '密码只能是英文字母或数字',
			'password.min' => '密码不得少于:min个字符',
			'password.max' => '密码不得超过:max个字符',
			'password.confirmed' => '您输入的密码不一致',
			'accepted.accepted' => '请勾选服务协议'
		];
    }
}
